﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Configuration.Provider;
namespace FOSystem.Infrastructure
{
    public class MyRoleProvider:RoleProvider
    {
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }
        public override string[] GetRolesForUser(string username)
        {
            if (username == null || username == "")
                throw new ProviderException("User name cannot be empty or null");

            Bussiness.User.UserBLL userbll = new Bussiness.User.UserBLL();
            var users = userbll.seachUser(username);
             
            return userbll.RoleForUser(username);
        }
        public override bool IsUserInRole(string username, string roleName)
        {
            if (username == null || username == "")
                throw new ProviderException("User name cannot be empty or null");
            if (roleName == null || roleName == "")
                throw new ProviderException("Role name cannot be empty or null");
            Bussiness.User.UserBLL userbll = new Bussiness.User.UserBLL();
            var users = userbll.seachUser(username);
                        bool inrole = false;
            if(users.GroupID==int.Parse(roleName))
                            inrole=true;
            return inrole;
        }
        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

       
        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

       

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }
}